<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      let arr = [10, 15, 20, 50, 70]

      while (arr.length < 5) {
        let num = Number(prompt(`请输入第${arr.length + 1}个人有效年龄`))
        if (num > 0 && num <= 100) {
          arr.push(num)
        }
      }
      console.log(arr)

      for (let i = 0; i < arr.length; i++) {
        if (arr[i] >= 18) {
          console.log(`已经成人的年龄是:${arr[i]}`)
        }
      }

      let Sum = 0

      for (let i = 0; i < arr.length; i++) {
        Sum += arr[i]
      }
      console.log(`所有人的总年龄:${Sum}`)
      console.log(`所有人的总年龄:${Sum / arr.length}`)

      let max = arr[0]
      let min = arr[0]
      for (let i = 1; i < arr.length; i++) {
        if (max <= arr[i]) {
          max = arr[i]
        }

        if (min >= arr[i]) {
          min = arr[i]
        }
      }

      console.log(`最大年龄：${max}`)
      console.log(`最大年龄：${min}`)
    </script>
  </body>
</html>
